home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Games Extra 1996 September
/
Amiga Games Extra CD-ROM 9-1996.iso
/
userbox
/
publicdomain
/
wbstars
/
source
/
wbstars_main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-09
|
3KB
|
182 lines
#include "WBStars_include.h"
#include "WBStars_protos.h"
#include "WBStars_gui.h"
long _stack=4000;
char *_procname="WBStars";
long _priority=0;
long _BackGroundIO=FALSE;
char version[30]={"$VER: WBStars 1.2 (09.07.96)"};
struct NewBroker newbroker = {
NB_VERSION,
"WBStars",
"Version 1.2 ©1996 by Alexander Pokahr",
"The Warp engine for Workbench !",
NBU_NOTIFY|NBU_UNIQUE, COF_SHOW_HIDE, 0, 0, 0
};
CxObj *broker;
struct MsgPort *broker_mp;
ULONG cxsigflag;
struct stars far star[MAXSTARS];
short az=AZI;
short he=HEI;
short az2=AZI;
short he2=HEI;
short wbs_pri=PRI;
char status=ACTIVE;
char mode=STRTMODE;
char anzstars=MAXSTARS;
char warpf=WRP;
short bgpen=BACKPEN;
char PEN[256]={2};
char npen=NPEN;
void _main( char *line )
{
CxMsg *msg;
if(OpenLibraries())
{
if (broker_mp = CreateMsgPort())
{
newbroker.nb_Port = broker_mp;
cxsigflag = 1L << broker_mp->mp_SigBit;
if (broker = CxBroker(&newbroker, NULL))
{
ActivateCxObj(broker, 1L);
LoadPrefs();
SetTaskPri(FindTask(0),wbs_pri);
Screen=NULL;
wnd=NULL;
Warp();
DeleteCxObj(broker);
while(msg = (CxMsg *)GetMsg(broker_mp))
{
ReplyMsg((struct Message *)msg);
}
}
DeletePort(broker_mp);
}
}
CloseLibraries();
}
void Warp()
{
char i;
while( CheckInteraction() )
{
if( status==ACTIVE )
{
for(i=0; i<anzstars; i++)
{
if( WinWait() )
{
ClearStar(i);
PlotStar(i);
}
else
{
break;
}
}
Delay( STAR_WAIT );
}
else
{
Delay( EVENT_WAIT );
}
}
}
void LoadPrefs()
{
BPTR fh;
char ch;
char dummy;
char n;
fh=Open("ENV:WBStars.prefs",MODE_OLDFILE);
if( !fh )
{
fh=Open("WBStars.prefs",MODE_OLDFILE);
}
if( fh )
{
while( Read(fh,&ch,1) )
{
switch( ch )
{
case 83 :
Read(fh,&dummy,1);
anzstars=NumF(fh);
anzstars=min(anzstars,MAXSTARS);
break;
case 87 :
Read(fh,&dummy,1);
warpf=NumF(fh);
warpf=min(warpf,9);
break;
case 66 :
Read(fh,&dummy,1);
bgpen=NumF(fh);
break;
case 84 :
Read(fh,&dummy,1);
wbs_pri=NumF(fh);
break;
case 77 :
Read(fh,&dummy,1);
mode=NumF(fh);
mode=!(mode==MODE_SCREEN);
break;
case 65 :
Read(fh,&dummy,1);
az=NumF(fh);
az2=az;
break;
case 72 :
Read(fh,&dummy,1);
he=NumF(fh);
he2=he;
break;
case 80 :
n=NumF(fh);
PEN[n]=NumF(fh);
npen=max(npen,n);
break;
}
}
Close( fh );
}
}
short NumF( BPTR fh )
{
char ch;
char ok;
short sig=1;
short num=0;
ok=Read(fh,&ch,1);
if(ch==45)
{
sig=-1;
ok=Read(fh,&ch,1);
}
while( ch<58 && ch>47 && ok )
{
num=num*10+ch-48;
ok=Read(fh,&ch,1);
}
return sig*num;
}